package qf.com.day8;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this,"demo");
        DaoMaster master = new DaoMaster(helper.getWritableDb());
        PersonDao dao = master.newSession().getPersonDao();
//        Person person = new Person(4,"赵武",20,false);
//        dao.insertOrReplace(person);
//        dao.insertOrReplace(new Person(5,"赵武1",12,false));
//        dao.insertOrReplace(new Person(6,"赵武2",24,false));
//        dao.insertOrReplace(new Person(7,"赵武3",114,false));
        List<Person> list1 = dao.queryBuilder()
                .where(PersonDao.Properties.Age.gt(16))
                .build().list();
        for (Person person : list1) {
            person.setGrow(false);
        }
        List<Person> list = dao.loadAll();
        for (Person person1 : list) {
            Log.i("info", "onCreate: "+person1.getName()+"  "+ person1.getAge()+"   "+person1.getGrow());
        }
        Intent intent = new Intent(this,Top.class);
        startActivity(intent);
    }


}
